-
-
Notifications
You must be signed in to change notification settings - Fork 746
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Implement runner, API, and client code for Inquiries #3653
Conversation
Signed-off-by: Matt Oswalt <oswaltm@brocade.com>
Signed-off-by: Matt Oswalt <oswaltm@brocade.com>
Signed-off-by: Matt Oswalt <oswaltm@brocade.com>
Signed-off-by: Matt Oswalt <oswaltm@brocade.com>
I would prefer that this is done using the API, which can be done with a Python action Signed-off-by: Matt Oswalt <oswaltm@brocade.com>
Signed-off-by: Matt Oswalt <oswaltm@brocade.com>
Signed-off-by: Matt Oswalt <oswaltm@brocade.com>
Signed-off-by: Matt Oswalt <oswaltm@brocade.com>
Signed-off-by: Matt Oswalt <matt@keepingitclassless.net>
Signed-off-by: Matt Oswalt <matt@keepingitclassless.net>
Signed-off-by: Matt Oswalt <matt@keepingitclassless.net>
Signed-off-by: Matt Oswalt <matt@keepingitclassless.net>
Signed-off-by: Matt Oswalt <matt@keepingitclassless.net>
Signed-off-by: Matt Oswalt <matt@keepingitclassless.net>
Signed-off-by: Matt Oswalt <matt@keepingitclassless.net>
Signed-off-by: Matt Oswalt <matt@keepingitclassless.net>
Signed-off-by: Matt Oswalt <matt@keepingitclassless.net>
Signed-off-by: Matt Oswalt <matt@keepingitclassless.net>
Signed-off-by: Matt Oswalt <matt@keepingitclassless.net>
Signed-off-by: Matt Oswalt <matt@keepingitclassless.net>
Signed-off-by: Matt Oswalt <matt@keepingitclassless.net>
Signed-off-by: Matt Oswalt <matt@keepingitclassless.net>
Signed-off-by: Matt Oswalt <matt@keepingitclassless.net>
Signed-off-by: Matt Oswalt <matt@keepingitclassless.net>
Signed-off-by: Matt Oswalt <matt@keepingitclassless.net>
Signed-off-by: Matt Oswalt <matt@keepingitclassless.net>
Signed-off-by: Matt Oswalt <matt@keepingitclassless.net>
Signed-off-by: Matt Oswalt <matt@keepingitclassless.net>
Signed-off-by: Matt Oswalt <matt@keepingitclassless.net>
The from_dict function was too close to from_model; the only difference was that it skipped the call to cls._from_model So I just added a parameter to skip this, and in the Inquiries controller I can just convert the InquiryAPI dicts directly into InquiryResponseAPI instances, since the latter is more restrictive. Signed-off-by: Matt Oswalt <matt@keepingitclassless.net>
Signed-off-by: Matt Oswalt <matt@keepingitclassless.net>
PermissionType.INQUIRY_ALL | ||
] | ||
permission_grants = get_all_permission_grants_for_user(user_db=user_db, | ||
resource_types=resource_types, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Since no resource_id is passed here it looks like those permissions should be global (don't apply to a specific resource) if that's not already the case.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actually, I just saw the code below. I see the approach you went with.
Another approach would be to make those permission types global (don't apply to a specific resource), then you could get rid of that if len check below.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This was mostly because Inquiries are still just executions under the hood so I wasn't sure of a better way. I'll see if I can convert the permissions to a global type and get rid of this hack.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I took a stab at this in 7d828a2. It seems to work (at least the tests are happy, will do some additional testing later) and I'm very happy to s/inquiry:ask/inquiry
everywhere but I'm not confident that I satisfied your statement: you could get rid of that if len check below
. For now, I'm assuming by that you meant getting rid of the list comprehension, since there are other resolvers that do a len()
check, just in a much simpler way (just checking total len of permission_grants
). Let me know if I missed something there.
Signed-off-by: Matt Oswalt <matt@keepingitclassless.net>
…ies UID hack Signed-off-by: Matt Oswalt <matt@keepingitclassless.net>
Signed-off-by: Matt Oswalt <matt@keepingitclassless.net>
Signed-off-by: Matt Oswalt <matt@keepingitclassless.net>
Also fixed bug where the ID in the trigger payload was the ID of the Inquiry liveaction instead of the ActionExecution. Added test for it Signed-off-by: Matt Oswalt <matt@keepingitclassless.net>
Signed-off-by: Matt Oswalt <matt@keepingitclassless.net>
Quick update on some somewhat major changes:
|
Signed-off-by: Matt Oswalt <matt@keepingitclassless.net>
Signed-off-by: Matt Oswalt <matt@keepingitclassless.net>
Signed-off-by: Matt Oswalt <matt@keepingitclassless.net>
Signed-off-by: Matt Oswalt <matt@keepingitclassless.net>
11edf44
to
26069f9
Compare
…roperly Inquiries play a bit of surgery with the liveactions behind the scenes, so when an ActionChain resumes from a Inquiry pause, it correctly retrieves an updated result when it detects a state change it didn't previously know about. However, it doesn't update context_result, which is what ultimately gets passed into the Jinja renderer. So this makes sure the appropriate task results is updated in context_result Signed-off-by: Matt Oswalt <matt@keepingitclassless.net>
7a6f441
to
1fd73ba
Compare
Signed-off-by: Matt Oswalt <matt@keepingitclassless.net>
Signed-off-by: Matt Oswalt <matt@keepingitclassless.net>
Congrats! 👏 |
This PR introduces a new runner,
inquirer
, as well as API endpoints andst2client
changes necessary for working with Inquiries.Usage
Please review the corresponding st2docs PR for full usage documentation and examples.
New "Inquiry" Runner
This PR creates the
inquirer
runner, which forms the basis for "asking a question" in the middle of a Workflow.Based on previous and current (see below) design discussions, this runner is fairly simple:
pending
statusThe entire act of handling a response (including validation) and resuming the workflow is handled by the API, and is outside the scope of this runner. This runner's sole purpose is to pause the workflow and provide enough context for a 3rd party to make a proper response.
The
inquirer
runner supports a number of parameters with sensible defaults. These defaults can of course be overridden by passing them into the action upon invocation. The parameters used for an Inquiry will be placed in the actionresult
.API
For the time being, Inquiries are effectively treated as ActionExecutions, with a bit of additional logic, meaning we haven't built a full data model for Inquiries yet. This actually works pretty well, but there are a few "weird" things in this PR, especially around RBAC, because of this decision.
For the time being, the API is (hopefully) designed under the assumption that Inquiries may be their own data model in the future, and acts like it is today.
This API will provide:
GET /api/v1/inquiries
: Retrieve all InquiriesGET /api/v1/inquiries/{id}
: Retrieve a specific inquiry by IDPUT /api/v1/inquiries/{id}
: Provide response data to an Inquiryst2client
UpdatesThere are three new commands, one for each new API function:
st2 inquiry list
st2 inquiry get <id>
st2 inquiry respond <id> <response json>
I opted to keep command-line options to a minimum, as most of the options for the similar
st2 executions list
command are focused mainly on filtering, and Inquiries shouldn't be that long-lived. Inquiries (for now) are basically just executions with a certain status, and they shouldn't be in that status for long. So I added thelimit
option, but not much else. Let me know if you feel other filters, like datetime filters are required, but I'm thinking they shouldn't be necessary.Testing Instructions
This is a large and significant feature so manual testing before the merge is a good idea. Here are some things to test
Please first review the corresponding st2docs PR containing formal descriptions of what Inquiries are and how to use them (and please leave comments on that PR as needed too)
The following commands will check this branch out, and spin up a development instance of st2, with mistral, and install the client:
From there, you can create and execute workflows and rules that test Inquiries. Note the existing Mistral and ActionChain workflows in this branch that may serve as a good place to start.
There are a number of things that I feel would be useful to test, but by all means, go beyond this list:
core.ask
action), and respond to it. Confirm that the workflow initially pauses, then respond to the inquiry. Then confirm the workflow resumes. Also confirm that the response fails with invalid data (and workflow does not resume)schema
parameter with your own, and supply data that would only validate against thatcore.ask
on its own, and that it supports the same response behavior.core.st2.generic.inquiry
trigger. Note that this is just a PoC - a future PR will introduce proper chatops integration once this core functionality is vettedst2 inquiry get/list/respond
). Ensure the output is as you would expectinquiry:ask
; just useinquiry
). This was one area where not having a dedicated model for Inquiries made things difficult (though not impossible).users
orroles
runner parameters. This goes beyond RBAC and actually permits/denies a per-Inquiry responseAgain, please review the corresponding st2docs PR for full usage documentation and examples.
TODOs